package com.xuecheng.content.config;

import com.sun.org.apache.regexp.internal.RE;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author: Hes
 * @description 切面定义
 * @date: 2023/7/2 12:33
 */
@Component
@Aspect
public class AspectConfig {
    //定义切入点，给任意返回值 service包下的任意方法，任意的参数
    @Pointcut("execution(* com.xuecheng.content.service.impl.*ServiceImpl.*(..))")
    public void check() {

    }

    //根据满足切入点条件的方法增强,环绕通知，执行前和执行后，以proceed = joinPoint.proceed();分割
    @Around("check()")
    public Object logAdvice(ProceedingJoinPoint joinPoint) {

        Object proceed = null;
        try {
            proceed = joinPoint.proceed();
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
        return proceed;
    }
}
